package com.tfw.domain;



/**
 * @program: fruit-sale
 * @description: 水果
 * @author: Fuwen
 * @create: 2022-07-27 21:52
 **/
public class Fruit extends Good{
    @Override
    public Good buy(int count){
        if (this.getInventory()<count){
            throw new IllegalArgumentException("库存不足，只剩："+this.getInventory()+"个");
        }
        this.setInventory(this.getInventory()-count);
        Good good = new Fruit();
        good.setUuid(this.getUuid());
        good.setUnit(this.getUnit());
        good.setId(this.getId());
        good.setInventory(count);
        good.setName(this.getName());
        good.setUnitPrice(this.getUnitPrice());
        return good;
    }
}
